﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ExplorerService.Common.ServiceContracts;
using ExplorerService.Managers;

namespace ExplorerService.Communication
{
    public class ApplicationStreamingService : IApplicationStreamingService
    {
        public void UploadStreamChunk(Guid applicationId, Guid streamId, byte[] chunk, long bytesLeft)
        {
            if (!ApplicationSessionManager.Instance.ValidSessionId(applicationId)) throw new Exception("Invalid session ID");
            StreamManager.Instance.PublishChunk(streamId, chunk, bytesLeft);
        }

        public byte[] GetNextStreamChunk(Guid applicationId, Guid streamId)
        {
            if (!ApplicationSessionManager.Instance.ValidSessionId(applicationId)) throw new Exception("Invalid session ID");
            return StreamManager.Instance.GetNextStreamChunk(streamId);
        }
    }
}
